Skip to content

test(core): enforce transport exact optional compatibility#1767

Open
rechedev9 wants to merge 2 commits intomodelcontextprotocol:fweinberger/transport-exact-optional-typesfrom
rechedev9:pr1766-exact-optional-check
Open

test(core): enforce transport exact optional compatibility#1767
rechedev9 wants to merge 2 commits intomodelcontextprotocol:fweinberger/transport-exact-optional-typesfrom
rechedev9:pr1766-exact-optional-check

Conversation

@rechedev9
Copy link
Copy Markdown

Summary

  • add a dedicated exactOptionalPropertyTypes compile check for the Transport compatibility case
  • wire that check into @modelcontextprotocol/core's existing typecheck script
  • fix the adjacent createFetchWithInit RequestInit.headers assignment that fails once exact optional property types are actually enforced

Why

PR #1766 fixes the public type surface, but without compiling a targeted check under exactOptionalPropertyTypes: true the regression can still slip back in. When that check is enabled, createFetchWithInit also needs a small adjustment because assigning headers: undefined into RequestInit is rejected under exact optional property semantics.

Verification

  • pnpm --filter @modelcontextprotocol/core typecheck
  • pnpm --filter @modelcontextprotocol/core test -- transport.types.test.ts
  • pnpm --filter @modelcontextprotocol/core lint

@rechedev9 rechedev9 requested a review from a team as a code owner March 26, 2026 16:23
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 26, 2026

⚠️ No Changeset found

Latest commit: b6cb436

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/core Patch

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 26, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1767

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1767

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1767

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1767

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1767

commit: b6cb436

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant